package com.example.springbootsecurityjwt.controller;

import com.example.springbootsecurityjwt.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: SpringBoot-Security-JWT
 * @description: HelloController
 * @author: Coder_Pan
 * @create: 2022-03-21 21:53
 **/
@RestController
public class HelloController {
    final
    UserMapper userMapper;




    public HelloController( UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    /**
     * @PreAuthorize("hasAnyAuthority('test')") ==>添加权限
     * 如果用户拥有test权限hasAnyAuthority()方法返回值为true，否则为false
     * @return
     */
    @PreAuthorize("hasAnyAuthority('test')")
    @RequestMapping("/hello")
    public String hello() {
        return "hello";
    }

}
